from src.schedule_docx import Schedule
from docx import Document
from docx.shared import Pt, Cm
from docx.enum.section import WD_ORIENT
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT

# # 创建一个Document对象
# doc = Document()

# sec = doc.sections[0]
# sec.orientation = WD_ORIENT.LANDSCAPE
# sec.page_width = Cm(29.7)
# sec.page_height = Cm(21)
# sec.top_margin = Cm(0.5)
# sec.bottom_margin = Cm(0.5)
# sec.left_margin = Cm(1)
# sec.right_margin = Cm(1)

# paragraph = doc.add_paragraph("2024.9")
# paragraph.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
# paragraph.paragraph_format.space_after = 0
# run = paragraph.runs[0]
# run.font.name = '宋体'
# run.font.size = Pt(14)

# # 添加一个表格
# table = doc.add_table(rows=3, cols=3)
# table.style = 'Table Grid'
# for row in table.rows:
#     for cell in row.cells:
#         # run = cell.add_paragraph('a').runs[0]
#         run = cell.paragraphs[0].add_run('a')
#         run.font.name = '宋体'
#         run.font.size = Pt(10.5)
# # 合并单元格，参数为起始行、起始列、结束行、结束列
# table.cell(0, 0).merge(table.cell(1, 1))

# # 保存文档
# doc.save('merged_cells.docx')

sc = Schedule()
sc.load("example.docx")
sc.save("out.docx")
# print(sc.tables)